package mc.support.taobao.api;

import com.taobao.api.TaobaoRequest;
import com.taobao.api.request.ClouddataMbpDataGetRequest;
import com.taobao.api.response.ClouddataMbpDataGetResponse;

import java.util.HashMap;
import java.util.Map;

/**
 * Created with IntelliJ IDEA. <br/>
 * Author: francis Yun    <br/>
 * Date: 2013-11-26  <br/>
 */
public class GetCloudDataReq extends
        AbstractReq<GetCloudDataReq,ClouddataMbpDataGetResponse> {

    private Long sqlId;

    private Map<String,String> parameters;

    public GetCloudDataReq sqlId(Long sqlId) {
        this.sqlId = sqlId;
        return this;
    }

    public GetCloudDataReq addParameter(String column, String value) {
        if ( null == parameters ) {
            parameters = new HashMap<String, String>();
        }
        parameters.put( column, value );
        return this;
    }

    @Override
    protected TaobaoRequest toRequest() {
        ClouddataMbpDataGetRequest req = new ClouddataMbpDataGetRequest();

        if ( null != sqlId ) {
            req.setSqlId( sqlId );
        }

        if ( null != parameters ) {
            req.setParameter( connectMap( parameters, "=", "," ) );
        }

        return req;
    }

}
